package cc.lj.internal.core.model;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.io.Serializable;
import java.util.List;

/**
 * @Description: 自定义分页对象
 * @Author: liangxifeng
 * @Date: 2021-06-25 15:31:18
 */
@Data
@NoArgsConstructor
@AllArgsConstructor
public class PageBean<T> implements Serializable {
    private static final long serialVersionUID = -2651141504856895125L;
    /**
     * 当前页
     */
    private int pageNum;
    /**
     * 每页大小
     */
    private int pageSize;
    /**
     * 总数
     */
    private int total;
    /**
     * 数据
     */
    private List<T> records;

    public static <T> PageBean<T> createPageBean(int pageNum, int pageSize, long total, List<T> records) {
        Integer size = Long.valueOf(total).intValue();
        PageBean<T> pageBean = new PageBean(pageNum, pageSize, size, records);
        return pageBean;
    }

}
